#include <algorithm>
#include <cstdio>
#include <cctype>
using namespace std;

int n;
int a[1001];
int b[1001];
bool v[1001];
int ans[1001];

void dfs(int step, int tot_ji, int tot_ou) {
	if (step == n - 1) {
		if (((max(tot_ji - tot_ou, tot_ou - tot_ji)) + 11) % 11 == 0) {
			int tmp = 1;
			while (tmp < n) {
				if (b[tmp] < ans[tmp]) {
					return;
				}
				if (b[tmp] > ans[tmp]) {
					for (int i = tmp; i < n; ++i) {
						ans[i] = b[i];
					}
					return;
				}
			}
		}
		return;
	}
	bool flag = (step + 1) & 1;
	for (int i = 1; i < n; ++i) {
		if (!v[i]) {
			v[i] = true;
			b[step + 1] = a[i];
			dfs(step + 1, flag ? tot_ji + a[i] : tot_ji, flag ? tot_ou : tot_ou + a[i]);
			b[step + 1] = 0;
			v[i] = false;
		}
	}
}
int main() {
	// freopen("testdata.in", "r", stdin);
	// freopen("testdata.out", "w", stdout);
	freopen("sort.in", "r", stdin);
	freopen("sort.out", "w", stdout);
	do {
		a[++n] = getchar() - '0';
	} while (isdigit(a[n] + '0'));
	dfs(0, 0, 0);
	for (int i = 1; i < n; ++i) {
		putchar(ans[i] + '0');
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}